package com.atguigu.classes;

/**
 * @program: IDEAcode
 * @description:字符串出现的次数
 * @author: Mr.zjx
 * create: 2021-07-24-23-56
 **/
public class Test09 {
    public static void main(String[] args) {
        getCount("sfhsKSFANSDJKL5345");
    }
    public static void getCount(String str){
        //定义三个计数器
        int upper = 0, lower = 0,number = 0;
        //先把字符串转为字符数组
        char[] chars = str.toCharArray();
        //遍历字符数组去除每个字符
        for (int i = 0; i < chars.length; i++){
            char c = chars[i];
            if ( c >= 'A' && c <= 'Z'){
                upper++;
            }else if ( c >= 'a' && c <= 'z'){
               lower++;
            }else if ( c >= '0' && c <= '9'){
                number++;
            }
        }
        System.out.println("大写字母："+ upper);
        System.out.println("小写字母："+ lower);
        System.out.println("数字："+ number);
    }
}
